package main

import "fmt"

func numberOfMatches(n int) int {
	sum := 0
	for n > 1 {
		sum += n / 2
		if n%2 == 0 {
			n = n / 2
		} else {
			n = n/2 + 1
		}
	}
	return sum
}

func main() {
	fmt.Println(numberOfMatches(100))
	fmt.Println(numberOfMatches(2))
}
